Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added new popwindow module in sugar3.graphics #313

Merged
merged 1 commit into from Jun 5, 2016

Conversation

devAbnull
Copy link
Contributor

@samdroid-apps , as discussed I have designed the pop-up model here.
Use of this can be seen in my PR in sugar repo.
Link-> sugarlabs/sugar#672


class PopWindow(Gtk.Window):
"""
UI interface for activity Pop-up Windows
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@quozl
Copy link
Contributor

quozl commented Apr 4, 2016

Please add more explanation to the commit description and force push. I've no idea what the intention of the patch is.

@@ -16,6 +16,7 @@ sugar_PYTHON = \
palettemenu.py \
palettewindow.py \
panel.py \
popwindow.py \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably mismatch of tab and space characters in this line compared to the lines either side, causing diff to show slight indentation.

@devAbnull devAbnull force-pushed the popup branch 2 times, most recently from 3ff1217 to bef7341 Compare April 5, 2016 19:04
@devAbnull devAbnull changed the title Base modal for all pop-up windows Refactoring the Pop-up windows in sugar, implemented a basic modal for pop-up windows Apr 5, 2016
@devAbnull
Copy link
Contributor Author

@samdroid-apps wrote docs for class and methods implemented.
@quozl commit message changed.

@quozl
Copy link
Contributor

quozl commented Apr 5, 2016

@AbrahmAB, thanks for changing the commit message, but perhaps I didn't say enough about it.

You wrote:

Refactoring the Pop-up windows in sugar, implemented a basic modal for pop-up windows

  • the patch looks like it adds a new module, but the message says it is a refactoring, (as if you mixed up the commit message with Refactor ViewSource as per sugarlabs/sugar-toolkit-gtk3#313 sugar#672),
  • there's no link in the commit message to the corresponding commit hash in the pull request of the other repository,
  • the first line of the message is too long, it wraps in displays, please use a shorter first line, then a blank line, then a paragraph of narrative or bullet points if necessary to explain,
  • sugar is redundant information, we know from context that this is a patch for Sugar,
  • look for ways to shorten the text, e.g. refactoring could be refactor, and pop-up windows need only be mentioned once.

Hope that helps! The purpose of commit messages is to communicate to other programmers now and in the future. Programmers who are doing a bisection to find the cause of a regression need as much information about the change as possible, yet in a form that is readily taken up.

These pop-up windows don't cover the whole screen.
They contain canvas content, alerts messages, a tray and a
toolbar.
"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please document the constructor kwargs in this section, eg:

Kwargs:
   title (type): what is it 
   set_titlebox (type): what is it 
   window_xid (type): what is it

@devAbnull
Copy link
Contributor Author

@samdroid-apps I have made the following changes in the code

  • Added document the constructor kwargs for PopWindow class.
  • Improved docs for get_vbox and get_scroll_window.
  • Replaced variable _sample_window with _scroll_window.
  • Removed the _add_events and copy of Gtk.Window methods like self._set_decorated etc.
  • Changed the method name _add_widget to add_widget in TitleBox.

@devAbnull
Copy link
Contributor Author

@quozl Thanks for your pointing out main points while writing a commit message.
I have changed the commit message again. Hope, that would be more informative! :)

@devAbnull devAbnull changed the title Refactoring the Pop-up windows in sugar, implemented a basic modal for pop-up windows Added new popwindow module in sugar3.graphics Apr 5, 2016
devAbnull added a commit to devAbnull/sugar that referenced this pull request Apr 5, 2016
devAbnull added a commit to devAbnull/sugar that referenced this pull request Apr 5, 2016
devAbnull added a commit to devAbnull/sugar that referenced this pull request Apr 5, 2016
@devAbnull
Copy link
Contributor Author

Oops! I made some typo error while changing the commit message of my PR in sugar repo having reference of this PR, for which I had to commit --amend -m again. I apologize for multiple reference links above :(.

@samdroid-apps
Copy link
Contributor

The api looks good. I'm afk so I cant test it, but I'm sure that @quozl can merge it if he is satisfied.

@quozl
Copy link
Contributor

quozl commented Apr 15, 2016

Happy to merge into my fork, but I don't think I have community support to merge into Sugar Labs.

@i5o
Copy link
Contributor

i5o commented Apr 18, 2016

I will test ASAP.

Hi everyone btw.

HALF_WIDTH = ((Gdk.Screen.height() - style.GRID_CELL_SIZE * 5)/2,
(Gdk.Screen.height() - style.GRID_CELL_SIZE * 3))

def __init__(self, set_titlebox=True, window_xid=None, **kwargs):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This patch is looking great. Just 2 little changes that might polish it up:

  1. Could we remove the "set_titlebox" property? Most people will just use the titlebox, and it can always be removed via get_titlebox().hide().
  2. Could you add a property or constructor argument that takes one of the size constants?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding props for size(having tuple of width, height) or separate for width and height.
I would prefer the separate properties. What are your suggestions @samdroid-apps ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having just one prop would be very good developer experience:

popup = PopWindow(PopWindow.FULLSCREEN)

On Thu, Apr 21, 2016 at 7:55 AM, Abhijit Patel
notifications@github.com wrote:

In src/sugar3/graphics/popwindow.py:

  • They contain canvas content, alerts messages, a tray and a
  • toolbar.
  • FULLSCREEN and HALF_WIDTH for setting size of the window.
  • Kwargs:
  •    set_titlebox (bool): False if titlebox is not needed
    
  •    window_xid (xlib.Window): xid of the parent window
    
  • """
  • FULLSCREEN = (Gdk.Screen.width() - style.GRID_CELL_SIZE * 5,
  •              Gdk.Screen.height() - style.GRID_CELL_SIZE \* 3)
    
  • HALF_WIDTH = ((Gdk.Screen.height() - style.GRID_CELL_SIZE *
    5)/2,
  •              (Gdk.Screen.height() - style.GRID_CELL_SIZE \* 3))
    
  • def init(self, set_titlebox=True, window_xid=None,
    **kwargs):
    Adding props for size(having tuple of width, height) or separate for
    width and height.
    I would prefer the separate properties. What are your suggestions
    @samdroid-apps ?


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub

@devAbnull
Copy link
Contributor Author

Changes made:

  1. Removed set_title_box property.
  2. Added constructor argument size .

def __init__(self):
ToolbarBox.__init__(self)

self.close_button = ToolButton(icon_name='dialog-cancel')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was just testing as I was integrating this into bibliography activity. Can you set the "tooltip=_('Close')", to be consistent with existing popups?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tooltip set 👍

@samdroid-apps
Copy link
Contributor

I will do a code review soon, but 1st there are some issues to fix:

screenshot from 2016-05-24 16-28-34
Toolbar adding padding - the label should be on the very right and the buttons on the very left

screenshot from 2016-05-24 16-25-26
Left buttons are in the wrong order, padding is an issue

screenshot from 2016-05-24 16-24-12
Left buttons are in the wrong order, padding is an issue

# the child class to display the window after modifications
# like chaninging window size, decorating, changing position.

#self.show()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this commented code

@devAbnull
Copy link
Contributor Author

Forced push with changes:

  • Fixed padding issue :) used Gtk.Toolbar instead of sugar3.graphics.ToolbarBox
  • Removed commented codes
  • Added docs string with example as per the syntax
  • GObject.Property for size , title_box, vbox, TitleBox.title
  • Removed add_widget method in TitleBox class

@samdroid-apps samdroid-apps merged commit a803876 into sugarlabs:master Jun 5, 2016
@samdroid-apps
Copy link
Contributor

Awsome! Merged! I can't wait to refactor my activities to use this.

# like chaninging window size, decorating, changing position.

def set_size(self, size):
width, height = size
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This way of assigning two variable with one value isn't right. It should be somewhat like this width, height = size_x, size_y

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, you pass a tuple;

tuple = (1, 200)
a, b = tuple

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The argument for this function is tuple of size itself!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah.. Got it

@iamutkarshtiwari
Copy link
Contributor

I am using this module for my 'Screenshot' popup. But whenever I click a snapshot, before the popup shows up on the screens, I see a grey rectange appear for a small fraction of second (which also get's captured in my screenshot'). You can see it in the attached screenshot below -
desktop-animation

Captured screenshot below -

data

@quozl
Copy link
Contributor

quozl commented Jun 15, 2016

Possibly a window realisation and size negotiation race.

The early stages of PopWindow.__init__ may be forcing Gtk to create the Gdk window in order to set the attributes requested. However, at the time this happens, there are no children in the window to negotiate a size. The children are added later.

You might experiment by moving parts of PopWindow.__init__ around; add the child widgets as soon as possible. Then call self.connect for the realize event. Then make the other calls. Then call self.connect for the remaining events.

Or, perhaps @AbrahmAB's design feature of not calling self.show (see comments at end of __init__) may need to be revisited.

@devAbnull
Copy link
Contributor Author

Hi Utkarsh,
I tried testing your patch but its showing the following traceback in my log
Traceback (most recent call last):
File "/home/broot/sugar-build/build/out/install/lib/python2.7/site-packages/jarabe/frame/devicestray.py", line 34, in __init__
locals(), [module_name])
File "/home/broot/sugar-build/build/out/install/share/sugar/extensions/deviceicon/display.py", line 37, in <module>
from jarabe.screenshotpanel.gui import ScreenshotPanel
ImportError: No module named screenshotpanel.gui

@quozl
Copy link
Contributor

quozl commented Jun 16, 2016

@AbrahmAB, the error shows file gui.py is missing; check that you have properly applied the patches in the pull request and that a file gui.py is in the screenshotpanel directory. See how sugarlabs/sugar@02636de adds that file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants