Browse Source

corrected errors

Nicole Portas 1 tháng trước cách đây
mục cha
commit
70a568e0b8
1 tập tin đã thay đổi với 13 bổ sung5 xóa
  1. 13 5
      src/main.cpp

+ 13 - 5
src/main.cpp

@@ -85,7 +85,8 @@ struct LoadedItem {
 class RenamerWindow : public Gtk::Window {
 class RenamerWindow : public Gtk::Window {
 public:
 public:
     RenamerWindow() : m_Dispatcher() {
     RenamerWindow() : m_Dispatcher() {
-        set_title("Simple Image Renamer 0.3");
+        // --- VERSION 0.3.1 ---
+        set_title("Simple Image Renamer 0.3.1");
         set_default_size(1280, 850);
         set_default_size(1280, 850);
         
         
         set_wmclass("simpleimagerenamer", "simpleimagerenamer");
         set_wmclass("simpleimagerenamer", "simpleimagerenamer");
@@ -199,8 +200,11 @@ public:
         m_MenuPopup.append(m_MenuItemSelectNone);
         m_MenuPopup.append(m_MenuItemSelectNone);
 
 
         m_MenuPopup.show_all();
         m_MenuPopup.show_all();
+        // FIX 1: Attach menu to widget (required in some GTK versions/contexts)
+        m_MenuPopup.attach_to_widget(m_IconView); 
 
 
-        // Connect Button Press Event for Right Click
+        // FIX 2: Explicitly enable button press events for SELECTION_NONE mode
+        m_IconView.add_events(Gdk::BUTTON_PRESS_MASK); 
         m_IconView.signal_button_press_event().connect(sigc::mem_fun(*this, &RenamerWindow::on_iconview_button_press), false);
         m_IconView.signal_button_press_event().connect(sigc::mem_fun(*this, &RenamerWindow::on_iconview_button_press), false);
         // ----------------------------------------
         // ----------------------------------------
 
 
@@ -311,6 +315,8 @@ protected:
         int count = 0;
         int count = 0;
         for (auto row : m_RefListStore->children()) {
         for (auto row : m_RefListStore->children()) {
             std::string original = row[m_Columns.m_col_filename], meta = row[m_Columns.m_col_info_str], new_name = original;
             std::string original = row[m_Columns.m_col_filename], meta = row[m_Columns.m_col_info_str], new_name = original;
+            
+            // Only modify name if checked
             if (row[m_Columns.m_col_checked]) {
             if (row[m_Columns.m_col_checked]) {
                 if (mode == 0 && !pattern.empty()) {
                 if (mode == 0 && !pattern.empty()) {
                     std::string num = std::to_string(start_num + count);
                     std::string num = std::to_string(start_num + count);
@@ -325,6 +331,7 @@ protected:
                     if (pos != std::string::npos) { new_name = original; new_name.replace(pos, m_EntryFind.get_text().length(), m_EntryReplace.get_text()); }
                     if (pos != std::string::npos) { new_name = original; new_name.replace(pos, m_EntryFind.get_text().length(), m_EntryReplace.get_text()); }
                 }
                 }
             }
             }
+
             std::stringstream mu; mu << "<span font='9'>";
             std::stringstream mu; mu << "<span font='9'>";
             if (new_name != original) mu << "<span size='small' alpha='60%'>" << Glib::Markup::escape_text(original) << "</span>\n<span foreground='#3584e4' weight='bold'>" << Glib::Markup::escape_text(new_name) << "</span>";
             if (new_name != original) mu << "<span size='small' alpha='60%'>" << Glib::Markup::escape_text(original) << "</span>\n<span foreground='#3584e4' weight='bold'>" << Glib::Markup::escape_text(new_name) << "</span>";
             else mu << "<span weight='bold'>" << Glib::Markup::escape_text(original) << "</span>";
             else mu << "<span weight='bold'>" << Glib::Markup::escape_text(original) << "</span>";
@@ -342,8 +349,9 @@ protected:
         int count = 0;
         int count = 0;
         
         
         for (auto row : m_RefListStore->children()) {
         for (auto row : m_RefListStore->children()) {
-            if (!row[m_Columns.m_col_checked]) continue;
-            
+            // Strict check for unchecked items
+            if (!row[m_Columns.m_col_checked]) continue; 
+
             std::string orig = row[m_Columns.m_col_filename], next = orig;
             std::string orig = row[m_Columns.m_col_filename], next = orig;
             if (mode == 0) {
             if (mode == 0) {
                 std::string num = std::to_string(start + count);
                 std::string num = std::to_string(start + count);
@@ -511,7 +519,7 @@ protected:
 
 
 int main(int argc, char *argv[]) {
 int main(int argc, char *argv[]) {
     Glib::thread_init(); 
     Glib::thread_init(); 
-    auto app = Gtk::Application::create(argc, argv, "org.gtkmm.renamer_v03");
+    auto app = Gtk::Application::create(argc, argv, "org.gtkmm.renamer_v03_1");
     RenamerWindow window;
     RenamerWindow window;
     return app->run(window);
     return app->run(window);
 }
 }